import Vue from 'vue';
import VueRouter from 'vue-router';
import index from '../views/index.vue';
import login from '../views/login.vue';
import forgot from '../views/forgot.vue';
import register from '../views/register.vue';
Vue.use(VueRouter)

const routes = [
    // 主页
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            index: 0,
            title: '首页'
        }
    },

    // 登录
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: {
            index: 0,
            title: '登录'
        }
    },

            // 注册
        {
            path: '/register',
            name: 'register',
            component: register,
            meta: {
                index: 0,
                title: '注册'
            }
        },
    	
	
    // 忘记密码
    {
        path: '/forgot',
        name: "forgot",
        component: forgot,
        meta: {
            index: 0,
            title: '忘记密码'
        }
    },

    // 修改密码
    {
        path: '/user/password',
        name: "password",
        component: () => import("../views/user/password.vue"),
        meta: {
            index: 0,
            title: '修改密码'
        }
    },

    // 视频播放页
    {
        path: "/media/video",
        name: "video",
        component: () => import('../views/media/video.vue'),
        meta: {
            index: 0,
            title: "视频"
        }
    },

    // 音频播放页
    {
        path: "/media/audio",
        name: "audio",
        component: () => import('../views/media/audio.vue'),
        meta: {
            index: 0,
            title: "音频"
        }
    },

    
    
                // 轮播图路由
        {
            path: '/slides/table',
            name: 'slides_table',
            component: () => import('../views/slides/table.vue'),
            meta: {
                index: 0,
                title: '轮播图列表'
            }
        },
        {
            path: '/slides/view',
            name: 'slides_view',
            component: () => import('../views/slides/view.vue'),
            meta: {
                index: 0,
                title: '轮播图详情'
            }
        },
                    // 文章路由
            {
                path: '/article/table',
                name: 'article_table',
                component: () => import('../views/article/table.vue'),
                meta: {
                    index: 0,
                    title: '邮件招聘列表'
                }
            },
            {
                path: '/article/view',
                name: 'article_view',
                component: () => import('../views/article/view.vue'),
                meta: {
                    index: 0,
                    title: '邮件招聘详情'
                }
            },

            // 文章分类路由
            {
                path: '/article_type/table',
                name: 'article_type_table',
                component: () => import('../views/article_type/table.vue'),
                meta: {
                    index: 0,
                    title: '邮件招聘分类列表'
                }
            },
            {
                path: '/article_type/view',
                name: 'article_type_view',
                component: () => import('../views/article_type/view.vue'),
                meta: {
                    index: 0,
                    title: '邮件招聘分类详情'
                }
            },
                            
            // 留言板路由
        {
            path: '/message/table',
            name: 'message_table',
            component: () => import('../views/message/table.vue'),
            meta: {
                index: 0,
                title: '留言反馈列表'
            }
        },
        {
            path: '/message/view',
            name: 'message_view',
            component: () => import('../views/message/view.vue'),
            meta: {
                index: 0,
                title: '留言反馈详情'
            }
        },
    
            // 论坛路由
        {
            path: '/forum/table',
            name: 'forum_table',
            component: () => import('../views/forum/table.vue'),
            meta: {
                index: 0,
                title: '论坛列表'
            }
        },
        {
            path: '/forum/view',
            name: 'forum_view',
            component: () => import('../views/forum/view.vue'),
            meta: {
                index: 0,
                title: '论坛详情'
            }
        },

        // 论坛分类路由
        {
            path: '/forum_type/table',
            name: 'forum_type_table',
            component: () => import('../views/forum_type/table.vue'),
            meta: {
                index: 0,
                title: '论坛分类列表'
            }
        },
        {
            path: '/forum_type/view',
            name: 'forum_type_view',
            component: () => import('../views/forum_type/view.vue'),
            meta: {
                index: 0,
                title: '论坛分类详情'
            }
        },
    
            // 公告路由
        {
            path: '/notice/table',
            name: 'notice_table',
            component: () => import('../views/notice/table.vue'),
            meta: {
                index: 0,
                title: '公告消息列表'
            }
        },
        {
            path: '/notice/view',
            name: 'notice_view',
            component: () => import('../views/notice/view.vue'),
            meta: {
                index: 0,
                title: '公告消息详情'
            }
        },
            	    
            // 评论路由
        {
            path: '/comment/table',
            name: 'comment_table',
            component: () => import('../views/comment/table.vue'),
            meta: {
                index: 0,
                title: '评论列表'
            }
        },
        {
            path: '/comment/view',
            name: 'comment_view',
            component: () => import('../views/comment/view.vue'),
            meta: {
                index: 0,
                title: '评论详情'
            }
        },
        	            // 企业用户路由
        {
            path: '/enterprise_user/table',
            name: 'enterprise_user_table',
            component: () => import('../views/enterprise_user/table.vue'),
            meta: {
                index: 0,
                title: '企业用户列表'
            }
        },
        {
            path: '/enterprise_user/view',
            name: 'enterprise_user_view',
            component: () => import('../views/enterprise_user/view.vue'),
            meta: {
                index: 0,
                title: '企业用户详情'
            }
        },
						            // 普通用户路由
        {
            path: '/ordinary_user/table',
            name: 'ordinary_user_table',
            component: () => import('../views/ordinary_user/table.vue'),
            meta: {
                index: 0,
                title: '普通用户列表'
            }
        },
        {
            path: '/ordinary_user/view',
            name: 'ordinary_user_view',
            component: () => import('../views/ordinary_user/view.vue'),
            meta: {
                index: 0,
                title: '普通用户详情'
            }
        },
						            // 线下招聘路由
        {
            path: '/offline_recruitment/table',
            name: 'offline_recruitment_table',
            component: () => import('../views/offline_recruitment/table.vue'),
            meta: {
                index: 0,
                title: '线下招聘列表'
            }
        },
        {
            path: '/offline_recruitment/view',
            name: 'offline_recruitment_view',
            component: () => import('../views/offline_recruitment/view.vue'),
            meta: {
                index: 0,
                title: '线下招聘详情'
            }
        },
						            // 岗位分类路由
        {
            path: '/post_classification/table',
            name: 'post_classification_table',
            component: () => import('../views/post_classification/table.vue'),
            meta: {
                index: 0,
                title: '岗位分类列表'
            }
        },
        {
            path: '/post_classification/view',
            name: 'post_classification_view',
            component: () => import('../views/post_classification/view.vue'),
            meta: {
                index: 0,
                title: '岗位分类详情'
            }
        },
						            // 线上招聘路由
        {
            path: '/online_recruitment/table',
            name: 'online_recruitment_table',
            component: () => import('../views/online_recruitment/table.vue'),
            meta: {
                index: 0,
                title: '线上招聘列表'
            }
        },
        {
            path: '/online_recruitment/view',
            name: 'online_recruitment_view',
            component: () => import('../views/online_recruitment/view.vue'),
            meta: {
                index: 0,
                title: '线上招聘详情'
            }
        },
						            // 简历投递路由
        {
            path: '/resume_delivery/table',
            name: 'resume_delivery_table',
            component: () => import('../views/resume_delivery/table.vue'),
            meta: {
                index: 0,
                title: '简历投递列表'
            }
        },
        {
            path: '/resume_delivery/view',
            name: 'resume_delivery_view',
            component: () => import('../views/resume_delivery/view.vue'),
            meta: {
                index: 0,
                title: '简历投递详情'
            }
        },
						            // 面试邀请路由
        {
            path: '/interview_invitation/table',
            name: 'interview_invitation_table',
            component: () => import('../views/interview_invitation/table.vue'),
            meta: {
                index: 0,
                title: '面试邀请列表'
            }
        },
        {
            path: '/interview_invitation/view',
            name: 'interview_invitation_view',
            component: () => import('../views/interview_invitation/view.vue'),
            meta: {
                index: 0,
                title: '面试邀请详情'
            }
        },
						            // 面试结果路由
        {
            path: '/interview_results/table',
            name: 'interview_results_table',
            component: () => import('../views/interview_results/table.vue'),
            meta: {
                index: 0,
                title: '面试结果列表'
            }
        },
        {
            path: '/interview_results/view',
            name: 'interview_results_view',
            component: () => import('../views/interview_results/view.vue'),
            meta: {
                index: 0,
                title: '面试结果详情'
            }
        },
						    	    // 用户路由
    {
        path: '/user/table',
        name: 'user_table',
        component: () => import('../views/user/table.vue'),
        meta: {
            index: 0,
            title: '用户列表'
        }
    },
    {
        path: '/user/view',
        name: 'user_view',
        component: () => import('../views/user/view.vue'),
        meta: {
            index: 0,
            title: '用户详情'
        }
    },
    {
        path: '/user/info',
        name: 'user_info',
        component: () => import('../views/user/info.vue'),
        meta: {
            index: 0,
            title: '个人信息'
        }
    },
    // 用户组路由
    {
        path: '/user_group/table',
        name: 'user_group_table',
        component: () => import('../views/user_group/table.vue'),
        meta: {
            index: 0,
            title: '用户组列表'
        }
    },
    {
        path: '/user_group/view',
        name: 'user_group_view',
        component: () => import('../views/user_group/view.vue'),
        meta: {
            index: 0,
            title: '用户组详情'
        }
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    let token = to.query.token;
    if (token) {
        $.db.set("token", token, 120);
    }
    next();
})

router.afterEach((to, from, next) => {
    let title = "校园招聘系统-admin";
    document.title = title;
})

export default router
